package com.leon.document_auto_generation_tool.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Closeable;
import java.io.IOException;

/**
 * @author XiaoZeguang
 * @creatTime 2023-04-23
 */
public class IoUtils {

    private static final Logger logger = LoggerFactory.getLogger(IoUtils.class);

    public static void closeAll(Closeable... closeables) throws IOException {
        if (closeables != null) {
            for (Closeable closeable : closeables) {
                if (closeable != null) {
                    try {
                        closeable.close();
                    } catch (IOException e) {
                        logger.error("关闭 IO 流过程中出现异常", e);
                        throw e;
                    }
                }
            }
        }
    }
}
